package com.parking.mgr.common.config;

import com.parking.mgr.common.error.CommonErrorAttributes;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName WebMvcConfig
 * @Description TODO
 * @author: zhijianpu
 * @Date: 2025/2/28
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 错误消息提示重写
     * @return
     */
    @Bean
    public CommonErrorAttributes commonErrorAttributes() {
        return new CommonErrorAttributes();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //swagger增强的静态资源映射
        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

}
